﻿
using Mengsk.ProxyDelivery.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mengsk.ProxyDelivery.Service
{
    public class OperatorLoginHistoryService : ServiceBase<OperatorLoginHistory>
    {
        private DateTime FormatTime(DateTime? time)
        {
            if (time == null || time.Value == DateTime.MinValue)
            {
                return this.GetDBMinTime();
            }
            return time.Value;
        }

        public DataCollection<OperatorLoginHistory> GetByAll(string number, int result, DateTime? startTime, DateTime? endTime,int pageIndex,int pageSize)
        {
            Request req = new Request { Api = "getByAll" };
            req.Parameters.Add(new Parameter { Name = "number", Value = number == null ? "" : number });
            req.Parameters.Add(new Parameter { Name = "ipAddress", Value = "" });
            req.Parameters.Add(new Parameter { Name = "result", Value = result });
            req.Parameters.Add(new Parameter { Name = "source", Value = -1 });
            req.Parameters.Add(new Parameter { Name = "startTime", Value = FormatTime(startTime).Date });
            req.Parameters.Add(new Parameter { Name = "endTime", Value = FormatTime(endTime).Date.AddDays(1) });
            req.Parameters.Add(new Parameter { Name = "pageIndex", Value = pageIndex });
            req.Parameters.Add(new Parameter { Name = "pageSize", Value = pageSize });
            return this.DoRemoteCall<OperatorLoginHistory>(req).ToDataCollection();
        }
    }
}
